package com.hex.liyue;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

import com.hyphenate.chat.EMOptions;
import com.hyphenate.easeui.controller.EaseUI;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

/**
 * Created by WJ on 2016/6/8.
 */
public class LiYueApplication extends Application {
    private static Context instance;
    private static Handler mainHandler;
    private IWXAPI api;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        mainHandler = new Handler();
        //初始化环信
        initEM();
        // 微信注册初始化
        api = WXAPIFactory.createWXAPI(this, "wxbd7b91a516360a2a", true);
        api.registerApp("wxbd7b91a516360a2a");
    }

    /**
     * 初始化环信
     */
    private void initEM() {
        EMOptions options = new EMOptions();
        EaseUI.getInstance().init(instance, options);
    }

    /**
     * 获取全局上下文
     *
     * @return
     */
    public static Context getInstance() {
        return instance;
    }

    /**
     * 获取主线程
     */
    public static Handler getMainHandler() {
        return mainHandler;
    }
}
